package com.ruoyi.common.utils.bean;

import com.github.pagehelper.Constant;
import com.google.common.collect.ImmutableSet;
import com.ruoyi.common.banbeiPay.DesUtils;
import com.ruoyi.common.constant.Constants;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.util.Set;

@Setter
@Getter
@ToString
public class AppCreateOrderVo {


    private String P1_bizType;
    private String P2_orderId;
    private String P3_customerNumber;
    private String P4_payType;
    private String P5_orderAmount;
    private String P6_currency;
    private String P7_authcode;
    private String P8_appType;
    private String P9_notifyUrl;
    private String P10_successToUrl;
    private String P11_orderIp;
    private String P12_goodsName;
    private String P13_goodsDetail;
    private String P14_desc;
    /**特殊参数,排除签名*/
    private String P15_subMerchantId;
    private String P16_appId;
    private String P17_limitCreditPay;
    private String P18_goodsTag;
    private String P19_guid;
    private String P20_marketingRule;
    private String P21_identity;
    private String hbfqNum;
    private String deviceInfo;
    private String timeExpire;
    /**支付宝行业数据回流信息,排除签名*/
    private String industryRefluxInfo;
    /**排除签名*/
    private String termInfo;
    /**预授权场景参数,排除签名*/
    private String openId;
    /**预授权场景参数,排除签名*/
    private String authConfirmMode;
    /**商户自定义门店编码,排除签名*/
    private String storeId;
    /**区县编码,排除签名*/
    private String areaCode;

    /**分账参数开始(不签名)*/
    private String ruleJson;
    private String splitBillType;
    /**分账参数结束(不签名)*/

    private String sign;


    public void setRuleJson(String ruleJson) {
        System.out.println("ruleJson 明文 result:" + ruleJson);
        if (StringUtils.isNotBlank(ruleJson)) {
            try {
                ruleJson = DesUtils.encode(Constants.DES_APPPAY, ruleJson);
            } catch (Exception e) {
                System.out.println("error:" + e.getMessage());
            }
            System.out.println("ruleJson 3des result:" + ruleJson);
        }
        this.ruleJson = ruleJson;
    }

    /**
     * 需要加签的属性参数,要求加签的参数空值也签名
     * 看接口文档
     */
    public static final Set<String> NEED_SIGN_PARAMS = ImmutableSet.of("P1_bizType",
            "P2_orderId", "P3_customerNumber", "P4_payType", "P5_orderAmount",
            "P6_currency", "P7_authcode", "P8_appType", "P9_notifyUrl", "P10_successToUrl",
            "P11_orderIp", "P12_goodsName", "P13_goodsDetail", "P14_desc");
}
